package com.xbb.monitor.controller.monitor;

import com.xbb.monitor.entity.echarts.LineBean;
import com.xbb.monitor.service.CpuService;
import com.xbb.monitor.service.DiskService;
import com.xbb.monitor.service.MonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("monitor")
public class MonitorController {

    @Autowired
    private CpuService cpuService;
    @Autowired
    private DiskService diskService;
    @Autowired
    private MonitorService monitorService;

    @RequestMapping("cpu")
    public Map<String,Object> allData(String timeFlag){
        Map<String,Object> map = cpuService.daysData(timeFlag);
        return map;
    }

    @RequestMapping("disk")
    public Map<String,Object> allData(String timeFlag,String mont){
        Map<String,Object> map = monitorService.diskAjax(mont,timeFlag);
        return map;
    }

    @RequestMapping("test")
    public Object test(String timeFlag,String mont){
        mont = "eth0";
        Map<String,Object> map = monitorService.networkAjax(mont,timeFlag);
        Object o = map.get("results");
        return o;
    }

    @RequestMapping("test2")
    public Object test2(String timeFlag,String mont){
        mont = "/";
        Map<String,Object> map = monitorService.diskAjax(mont,timeFlag);
        Object o = map.get("kbs");
        return o;
    }
}
